# -*- coding: utf-8 -*-

#This file is part of pyLot library.
#
# pyLot is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# pyLot is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with pyLot.  If not, see <http://www.gnu.org/licenses/>.

__author__ = u'Pierre Puiseux, Guillaume Baty'
__copyright__ = u"Copyright 2011-2012 (C) andheo, Université de Pau et des Pays de l'Adour"
__credits__ = [u'Pierre Puiseux', u'Guillaume Baty']
__license__ = "GNU Lesser General Public License"

__all__ = ['CsvCollectionDataFormat', 'XmlCollectionDataFormat', ]

from pyLot.dataconverter import DataFormat

class CsvCollectionDataFormat(DataFormat):
  """
  classdocs
  """
  name = 'Csv Collection'
  exts = ['csv', 'dat']
  ext = 'csv'
  documentation = 'free-specs'
  restrictions = 'open'
  identifier = 'pyLot.format.csv_collection'

  example_text = u"""# Collection CSV file -- version : 0.1

@@Collection cmake;;;;;CMake and Build options;;CMake and Build

@Book general;;;;;build options;gr;General Options

  build_suffix;str;-build;;[-build];add suffix_build to build directory name;;Build directory suffix;devel
  cleancache;bool;True
  debug_mode;bool;False

@Book pathbook;Path;;;;Build paths;gr;Paths

  src;Path;;.;;Directory containing source files (.cxx, .tex, ...);;Source directory;expert
  build;Path;;;;Project build directory;;project build directory;expert
  builds;Path;;;;Directory containing object files (.o, .aux, ...);;Build directory;devel
  cmakeoptions;Path;;;;Directory containing saved CMake options;;CMake option directory
"""

class XmlCollectionDataFormat(DataFormat):
  """
  classdocs
  """
  name = 'Xml Collection'
  exts = ['xml']
  ext = 'xml'
  documentation = 'free-specs'
  restrictions = 'open'
  identifier = 'pyLot.format.xml_collection'
  encoding = 'utf-8'

  example_text = u"""<?xml version='1.0' encoding='utf-8'?>
<block alias="CMake and Build" name="cmake" tooltip="ά - CMake and Build options">
  <block alias="Paths" name="pathbook" tooltip="Build paths">
    <datum alias="Source directory" name="src" nature="Path" pymodule="_pylot.core.path" tooltip="Directory containing source files (.cxx, .tex, ...)">
      <value role="default">.</value>
    </datum>
    <datum alias="Build directory" name="builds" nature="Path" pymodule="_pylot.core.path" tooltip="Directory containing object files (.o, .aux, ...)" />
    <datum alias="project build directory" name="build" nature="Path" pymodule="_pylot.core.path" tooltip="Project build directory" />
    <datum alias="CMake option directory" name="cmakeoptions" nature="Path" pymodule="_pylot.core.path" tooltip="Directory containing saved CMake options" />
  </block>
  <block alias="General Options" name="general" tooltip="build options">
    <datum alias="Build directory suffix" name="build_suffix" nature="str" tooltip="add suffix_build to build directory name">
      <value role="current">-build</value>
      <value role="default" />
    </datum>
    <datum name="cleancache" nature="bool">
      <value role="current">True</value>
    </datum>
    <datum name="debug_mode" nature="bool">
      <value role="current">False</value>
    </datum>
  </block>
</block>
"""
